//
//  Enemy.m
//  FIght Game
//
//  Created by iD Student on 7/1/13.
//  Copyright (c) 2013 iD Student. All rights reserved.
//

#import "Enemy.h"

@interface Enemy ()

@end

@implementation Enemy
@synthesize imageView;
-(id)init
{
    
    alive = YES;
    pointValue = 1;
      appsettings = [NSUserDefaults standardUserDefaults];
      pic = [NSUserDefaults standardUserDefaults];
    
    return self;
}

-(UIImageView*)spawn
{
        imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed: [[NSString alloc] initWithFormat: @"enemy%d.png", [appsettings integerForKey:@"enemyType"]]]];
    int xpoint = arc4random()%(300-20)+20;
    int ypoint = arc4random()%(396-20)+20;
    imageView.center = CGPointMake(xpoint,ypoint);
    return imageView;
}
-(void) kill
{
    if(alive){
    
        imageView.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"1.png"],
                                                [UIImage imageNamed:@"2.png"],
                                                [UIImage imageNamed:@"3.png"],
                                                [UIImage imageNamed:@"4.png"],
                                                [UIImage imageNamed:@"5.png"],
                                                [UIImage imageNamed:@"6.png"], nil];
        imageView.animationDuration = .7;
       [imageView startAnimating];
            
    timer = [NSTimer scheduledTimerWithTimeInterval:.7 target:self selector:@selector(remove) userInfo:nil repeats:NO];
        pointValue = 0;
}

    alive = NO;

        }

-(void) remove{
    [imageView removeFromSuperview];
}

-(int)getPoints
{
    return pointValue;
}

-(BOOL) isAlive
{
    return alive;
}

@end
